import React, { useEffect, useState } from 'react'
import { root } from './index'

export default function App() {
  const [age, setAge] = useState(0)
  useEffect(() => {
    // 副作用回调函数
    console.log(1)
    return () => {
      // 清理函数
      console.log('~~')
    }
  }, [age])

  const handleClick = () => {
    // setAge(age + 1)
    root.unmount()
  }
  return (
    <div>
      <h3>{age}</h3>
      <button onClick={handleClick}>+1</button>
    </div>
  )
}
